

//购买商城物品 {"位置":1,"数量":"100","编号":1,"分类":"银子商城","组号":18}
// @ts-ignore
export async function execute(client_id,message_json) {
    //获取要购买的物品信息
    let key = message_json["分类"];
    let list = G.ShoppingMallData.default[key];


    if (list !== undefined) {
        //目标商品
        var goods = list[message_json["位置"] - 1];
        //购买数量
        let num = message_json["数量"];
        switch (key) {
            case "银两商城":
                buy_item_goods(client_id,goods,num);
                break;
            case "仙玉商城":
                buy_item_goods(client_id,goods,num);
                break;
            case "特殊商城":
                buy_item_goods(client_id,goods,num);
                break;
            case "锦衣祥瑞":
                buy_item_goods(client_id,goods,num);
                break;
            case "法宝商城":
                buy_item_goods(client_id,goods,num);
                break;
            case "宝宝商城":
                buy_item_goods(client_id,goods,num);
                break;
            default:
                break;
        }
    }
}

function buy_item_goods(client_id,goods,num) {
    //价格
    let price = goods["价格"];
    // //判断余额够不够
    // if (price*num > login_characters[key]){
    //     ClientUtils.send_basic_prompt(client_id,``+key+`余额不足`);
    // }else{
    //拿到物品名称

    let item_name = goods["名称"];
    let login_characters = G.Characters.get_current_login_characters(client_id);
    G.Characters.add_item(login_characters["id"], item_name, num, "商城购买");
}